﻿using System;
using System.Web.UI;
using Portal.Data.Config;
using Portal.Data.Entity;
using Portal.Data.Webparts;

public partial class Webparts_Templates_truyen_PagingBookByAuthor : WebpartControl
{
    public override WebpartConfig NewConfig
    {
        get { return new ContentPagingConfig(); }
    }

    public ContentPagingConfig PartConfig
    {
        get { return (ContentPagingConfig)Config; }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            var id = Convert.ToInt32(Common.GetViewId());
            if (id <= 0) return;
            var author = Author.FindByPrimaryKey(id);
            if (author == null) return;

            ltrHeader.Text = author.DisplayFullName;

            int pageindex = Common.GetCurrentPageIndex();
            var books = Book.PagingByAuthor(author.ID, pageindex);
            Items.DataSource = books;
            Items.DataBind();

            Page.Title = author.DisplayFullName + " | " + Common.GetString("Default", "PortalTitle");

            Common.PagingWithouTotalCount(new Control[] { phPagingBottom }, pageindex, books.Count);
        }
    }
}